package com.example.calculateshopprice;

import com.example.calculateshopprice.fruit.Fruit;
import com.example.calculateshopprice.fruitshop.CalFruitsPriceTotals;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import java.util.HashMap;
import java.util.Map;



@SpringBootApplication
public class CalculateShopPriceApplication {

    // 顾客 A 购买苹果和草莓
    public static void main(String[] args) {
        SpringApplication.run(CalculateShopPriceApplication.class, args);
        System.out.println("111111");
        CalFruitsPriceTotals    calFruitsPriceTotals  =new CalFruitsPriceTotals();


        Fruit apple = new Fruit("苹果", 8);
        Fruit strawberry = new Fruit("草莓", 13);
        CalFruitsPriceTotals A= new CalFruitsPriceTotals();

        A.addFruit(apple, 2); // 添加2斤苹果
        A.addFruit(strawberry, 5); // 添加5斤草莓
        System.out.println("顾客 A 的总价：" + A.calculateTotalPrice());

        // 顾客 B 购买苹果、草莓和芒果
        Fruit mangguo = new Fruit("芒果", 20);
        CalFruitsPriceTotals B = new CalFruitsPriceTotals();
        B.addFruit(apple, 5); // 添加5斤苹果
        B.addFruit(strawberry, 5); // 添加5斤草莓
        B.addFruit(mangguo, 1); // 添加1斤芒果
        System.out.println("顾客B的总价：" + B.calculateTotalPrice());

        // 顾客 C 购买苹果、草莓和芒果，草莓打 8 折
        CalFruitsPriceTotals C = new CalFruitsPriceTotals();
        C.addFruit(apple, 1); // 添加5斤苹果
        C.addFruit(strawberry, 1); // 添加3斤草莓
        C.addFruit(mangguo, 1); // 添加2斤芒果
        double totalC = C.calculateTotalPrice();
        if (totalC >= 0) {

        double down=1* 20*0.2;
            totalC=totalC-down;
                //  打 8 折

       }

        System.out.println("顾客 C 的总价：" + totalC);

        // 顾客 D 购买苹果、草莓和芒果，满 100 减 10
        CalFruitsPriceTotals D = new CalFruitsPriceTotals();
        D.addFruit(apple, 6); // 添加6斤苹果
        D.addFruit(strawberry, 4); // 添加4斤草莓
        D.addFruit(mangguo, 3); // 添加3斤芒果
        double totalD = D.calculateTotalPrice();
        if (totalD >= 100) {
            totalD -= 10; // 满减
        }
        System.out.println("顾客 D 的总价：" + totalD);
    }


        }




